package com.sjc.counter.v2;

import com.sjc.counter.entity.RequestStat;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl;


import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @Classname EmailViewer
 * @Description
 * @Date 2020/5/1 17:12
 * @Created by SangJiacun
 */
public class EmailViewer implements StatViewer {
    private JavaMailSender mailSender;
    private List<String> toAddresses = new ArrayList<>();

    public EmailViewer() {
        this.mailSender = new JavaMailSenderImpl();
    }

    public EmailViewer(List<String> address) {
        this();
        this.toAddresses = address;
    }

    public EmailViewer(JavaMailSender mailSender) {
        this.mailSender = mailSender;
    }

    public void addToAddress(String address) {
        toAddresses.add(address);
    }

    @Override
    public void output(Map<String, RequestStat> requestStats, long startTimeInMillis, long endTimeInMillis) {
        // format the request stats to HTML style
        // send it to email toAddresss.
    }
}
